﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NCS.Library;
using NCS.Library.Components.Portal;
using NCS.Library.Components.Security;
namespace Portal.Administrator
{
    public partial class Authenticate : AdminPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Redirect(AppEnv.ADMIN_CMD + "?portalid=" + AppEnv.PortalId());

            if (!IsPostBack)
            {
                lblCurrentUser.Text = CurrentUser.Username;
                if (AppEnv.GetLanguage() == "vi-VN")
                {
                    hplChangePass.Text = "Hồ sơ cá nhân";
                    btnLogout.Text = "Đăng xuất";
                    lblWellcome.Text = "Chào mừng :";
                    btnGo.ImageUrl = "/administrator/images/go.png";

                }
                else
                {
                    hplChangePass.Text = "Edit profile";
                    btnLogout.Text = "Log Out";
                    lblWellcome.Text = "Wellcome :";
                    btnGo.ImageUrl = "/administrator/images/go.png";
                }
                
                if (!CurrentUser.IsSuperAdmin && !CurrentUser.IsAdmin)
                {
                    PortalController.LoadPortalsForRadComboByUserID(dropPortal.Items, CurrentUser.UserID);
                }
                else
                {
                    PortalController.LoadPortalsForRadCombo(dropPortal.Items);
                }
                //dropPortal.SelectedIndex = -1;
               //btnGo_Click(null, null);
                btnGo.ImageUrl = "/administrator/images/go.png";
                hplChangePass.NavigateUrl = "/Administrator/Default.aspx?portalid=" + AppEnv.PortalId() + "&cmd=manageprofile&uid=" + CurrentUser.UserID + "&lang=" + AppEnv.GetLanguage();
                
            }
            
        }

        protected void btnGo_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect(AppEnv.ADMIN_CMD + "?portalid=" + dropPortal.SelectedValue);
        }

        protected void btnLogout_Click(object sender, EventArgs e)
        {
            AuthenticateUtility.LogoutUser();
            Response.Redirect("/Administrator/");
        }
    }
}
